﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GMS.BIZ;
using System.Data;
using System.Collections;

namespace Web.Paper
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (!((Account)Session["Account"]).RoleCurrent.Equals('c')) Response.Redirect("Default.aspx");
            ClassTeacher myClassTeacher = new ClassTeacher(((ClassTeacher)Session["ClassTeacher"]).TeacherId);
            if (((ClassTeacher)Session["ClassTeacher"]).TeacherName == "")
                Response.Redirect("~/Information/TeaInformation.aspx");
            if (!IsPostBack)
            {
                ArrayList arraylist = new ArrayList();
                arraylist = myClassTeacher.Classes.GetList();
                if (arraylist.Count == 0)
                    DropDownList_class.SelectedItem.Text = "空";
                for (int i = 0; i < arraylist.Count; i++)
                {
                    ListItem myListItem = new ListItem();
                    myListItem.Text = arraylist[i].ToString();
                    myListItem.Value = myListItem.Text;
                    DropDownList_class.Items.Add(myListItem);
                }
            }
            ClassInfo myClassInfo = new ClassInfo(DropDownList_class.SelectedValue);
            DataSet ds = myClassInfo.GetStudentsDataSet();
            if (ds.Tables[0].Rows.Count == 0)
                Label_NoData.Text = "该班级没有学生";
            GridView_StudentList.DataSource = ds;
            GridView_StudentList.DataBind();
        }

        protected void GridView_StudentList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView_StudentList.PageIndex = e.NewPageIndex;
            ClassTeacher myClassTeacher = new ClassTeacher(((ClassTeacher)Session["ClassTeacher"]).TeacherId);
            ClassInfo myClassInfo = new ClassInfo(DropDownList_class.SelectedValue);
            GridView_StudentList.DataSource = myClassInfo.GetStudentsDataSet();
            GridView_StudentList.DataBind();
        }
    }
}
